import 'package:flutter/material.dart';

class LoginPage extends StatefulWidget{

  @override

  LoginPageSate createState() => LoginPageSate();
}

class LoginPageSate extends State<LoginPage> {


  @override
  void dispose() {
    // TODO: implement dispose
    print("LoginPage");
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {

//    FocusNode focusNode = new FocusNode();
//    _requestFocus(){
//      FocusScope.of(context).requestFocus(focusNode);
//      return focusNode;
//    }

    final size = MediaQuery.of(context).size;
    final width = size.width;
    final height = size.height;
    final cardHeight = (size.width - 60) * 719.0/630.0;

//    TextEditingController _userUMAccountController = new TextEditingController();
//    TextEditingController _userPasswordController = new TextEditingController();

    // TODO: implement build
    return Scaffold(
      resizeToAvoidBottomPadding: false,
      body: Container(
        child: Stack(
          children: <Widget>[
            Image.asset("images/loading.png",width: width,height: height,fit: BoxFit.fill,),
            Positioned(
                child: Column(
                 crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    Card(
                      margin: EdgeInsets.only(left:30,right: 30,top: (height - 40 - 52 - cardHeight)/2.0),
                      color: Colors.white,
                      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
                      child: SizedBox(
                        height: cardHeight,
                        width: size.width - 60,
                        child: Column(
                          children: <Widget>[
                            Padding(
                              padding: const EdgeInsets.only(top: 43.0),
                            ),
                            Image.asset("images/logo.png",width:50 ,height: 50,
//                              color: Colors.whi,
                            ),
                            Padding(
                              padding: const EdgeInsets.only(top: 11.0),
                            ),
                            Text("智慧经分",style: TextStyle(
                              fontSize: 20.0,
                              fontWeight: FontWeight.bold,
                              color: Color(0xFF5A5D6C),
                              letterSpacing:6,
                            ),),
                            Padding(
                              padding: const EdgeInsets.only(top: 50.0),
                            ),
                            Container(
                              height: 58.0,
                              margin: const EdgeInsets.only(left: 20.0,right: 20.0),
                              alignment: Alignment.center,
                              child:Theme(
                                data: ThemeData(
                                    primaryColor: Colors.blue,
                                    primarySwatch: Colors.blue
                                ),
                                child: new TextField(
//                                  autofocus: true,
//                                  focusNode: _requestFocus(),
                                  style: TextStyle(color: Colors.black87,fontSize: 15.0),
                                  decoration: new InputDecoration(
                                      hintText: '请输入您的UM账号',
                                      enabledBorder: new OutlineInputBorder(  //添加边框
                                        borderSide: BorderSide(color: Color(0xFF6C7390),width: 0.5),
                                        borderRadius: BorderRadius.circular(5.0),
                                        gapPadding: 2.0,

                                      ),
                                      focusedBorder: new OutlineInputBorder(  //添加边框
                                        borderSide: BorderSide(color: Colors.blueAccent,width: 0.5),
                                        borderRadius: BorderRadius.circular(5.0),
                                      ),
                                      prefixIcon: new Icon(Icons.print),
                                      contentPadding: const EdgeInsets.all(5.0)
                                  ),
                                  keyboardType: TextInputType.text,
                                ),
                              )
                            ),
                            Padding(
                              padding: const EdgeInsets.only(top: 30.0),
                            ),
                            Container(
                              height: 58.0,
                              margin: const EdgeInsets.only(left: 20.0,right: 20.0),
                              alignment: Alignment.centerLeft,
                              child: Theme(
                                data: ThemeData(
                                  primaryColor: Colors.blue,
                                  primarySwatch: Colors.blue
                                ),
                                child: new TextField(
//                                  obscureText: true,
//                                  autofocus: true,
//                                  focusNode: _requestFocus(),
                                  style: TextStyle(color: Colors.black87,fontSize: 15.0),
                                  decoration: new InputDecoration(
                                      hintText: '请输入您的密码',
                                      enabledBorder: new OutlineInputBorder(  //添加边框
                                        borderSide: BorderSide(color: Color(0xFF6C7390),width: 0.5),
                                        borderRadius: BorderRadius.circular(5.0),
                                        gapPadding: 2.0,

                                      ),
                                      focusedBorder: new OutlineInputBorder(  //添加边框
                                        borderSide: BorderSide(color: Colors.blueAccent,width: 0.5),
                                        borderRadius: BorderRadius.circular(5.0),
                                      ),
                                      prefixIcon: new Icon(Icons.print),
                                      contentPadding: const EdgeInsets.all(5.0)
                                  ),
//                                  keyboardType: TextInputType.visiblePassword,
                                ),
                              )
                            ),
                          ],
                        ),
                      ),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 40,left: 30,right: 30),
                      child:  MaterialButton(onPressed: (){
                          print("登录");
                          Navigator.of(context).pushReplacementNamed("tabBarPage");
                      },
                        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(26)),
                        height: 52,
                        minWidth: size.width - 60,
                        child: Text("确认登录",
                          style: TextStyle(
                            fontSize:16.0,
                          ),
                        ),
                        textColor: Colors.white,
                        color: Color(0xFF008FF3),
                      ),
                    ),

                  ],
                )
            ),
          ],
        ),
      ),
    );
  }
}